<template>
  <div class="common-layout">
    <el-container>
      <el-header>
        <div class="header-content">
          <img style="height: 150px;width: 150px" src="@/logo.png" alt="Logo" class="header-logo">
          <div>
            <img src="@/img.png" alt="Logo-text" style="height: 45px;margin-top: 30px" class="header-logotext">
            <p STYLE="width: 1000px;margin-left: 10px;margin-top: 10px">NEUSOFT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SMART&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COMMUNITY</p>
          </div>
          <div class="avatar">
            <el-avatar :size="55" :icon="UserFilled"/>
          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside class="aside">
          <el-menu router default-active="1">
            <el-menu-item style="height: 100px" index="announcement-management" class="first">
              <el-icon>
                <location/>
              </el-icon>
              <span>公告发布</span>
            </el-menu-item>
            <el-menu-item style="height: 100px" index="complaints-management">
              <el-icon>
                <icon-menu/>
              </el-icon>
              <span>投诉管理</span>
            </el-menu-item>
            <el-menu-item style="height: 100px" index="visitor-management">
              <el-icon>
                <document/>
              </el-icon>
              <span>访客通行</span>
            </el-menu-item>
            <el-menu-item style="height: 100px" index="park-management">
              <el-icon>
                <setting/>
              </el-icon>
              <span>车位管理</span>
            </el-menu-item>
            <el-menu-item style="height: 100px" index="maintenance-management">
              <el-icon>
                <setting/>
              </el-icon>
              <span>报事处理</span>
            </el-menu-item>
            <el-menu-item style="height: 100px" index="payment-management">
              <el-icon>
                <setting/>
              </el-icon>
              <span>缴费记录</span>
            </el-menu-item>
          </el-menu>
        </el-aside>

        <el-main class="main">
          <router-view></router-view>
          <div class="issue-title"><h2>访客通行</h2></div>
          <el-divider></el-divider>
          <el-table
              :data="tableData"
              style="width: 100%">
            <el-table-column
                prop="visitorName"
                label="访客姓名"
                width="180">
            </el-table-column>
            <el-table-column
                prop="visitorEmail"
                label="访客邮箱"
                width="180">
            </el-table-column>
            <el-table-column
                prop="visitorPhoneNumber"
                label="访客手机号">
            </el-table-column>
            <el-table-column
                prop="visitorAddress"
                label="访客地址">
            </el-table-column>
            <el-table-column
                prop="visitorIdNumber"
                label="访客身份证号">
            </el-table-column>
            <el-table-column
                prop="visitorReason"
                label="访客原因">
            </el-table-column>


          </el-table>
        </el-main>

      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import {Document, Location, Menu as IconMenu, Setting, UserFilled} from '@element-plus/icons-vue'
import {ref} from 'vue';
import {onMounted} from "vue";
import *as visitor from "../api/visitor"

const tableData = ref([]);
onMounted(() => {
  visitor.queryVisitor().then((res) => {
    tableData.value=res.data;
    console.log(res.data);
  })
});
</script>
<style scoped>
.issue-title {
  text-align: left;
  margin-left: 80px;
//padding-left: 10%; /* “报事维修”文字距离屏幕左侧15%的位置 */ margin-top: 40px; /* 可选，为下部内容添加一些间距 */
}

.common-layout {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden; /* 隐藏滚动条 */
}

.avatar {
  margin-left: 400px;
}

.header-logo {
  float: left;
  width: 100px;
  height: auto;
  margin-top: 10px;
  margin-left: -175px;
}

.header-logotext {
  margin-top: 40px;
}

.header-content {
  display: flex;
  align-items: center;
  border-width: 1px;
  border-bottom-style: groove;
  border-bottom-color: #cccccc;
  position: absolute;
  left: 10%; /* 图片和标题距离左侧20% */
  width: 100%; /* 可根据实际情况调整，确保内容不会溢出 */
}

.aside {
  position: absolute;
  top: 160px;
  left: 0;
  bottom: 0;
  width: 200px;
  height: calc(100% - 60px);
  border: 1px solid #ccc;
}

span {
  font-size: 18px;
}

.first {
  margin-top: 0px;
}

.main {
  flex: 1; /* main占据剩余空间 */
  border-radius: 4px;
  position: absolute;
  top: 150px;
  left: 200px;
  right: 0;
  bottom: 0;
}

.el-header {
  flex: 0 0 15%; /* header占据20%高度，且不缩放 */
  line-height: 1; /* 重置line-height，避免继承影响 */
  align-items: center; /* 垂直居中 */
  justify-content: space-between; /* 调整为两端对齐，以便在两侧放置元素 */
  padding: 0px 20px; /* 添加内边距以防止内容贴近边缘 */
}
</style>